$('#tcmingchengqr .confirm').attr('id','btnYaoPinAdd');
$('form').validator({
	stopOnError:"true",
	rules: {
        numCheck: [/^-?\d{0,11}\.?\d{0,3}$/, "请填写有效的数字"],
    },
    fields: {
        'dancijl': '单次剂量:numCheck',
        'morenkyl': '默认开药量:numCheck',
        'kucunsl': '库存:numCheck'
    }
});
$("#formSave").keyup(function (event) {
	keyCode = event.which;
});
//精确查找
$(document).off('click', '#jingqueczsp');
$(document).on('click','#jingqueczsp',function(){
	var mingcchen = $(this).parent().parent().find(".mingchengtxm").val();
	var kucunsl = $('#kucun').val();
	$(this).parent().parent().find(".mingchengtxm").val('').addClass('qiaojie');
	$("input").val('');
	$(".dropdown-toggle").val('');
	$(".dropdown-toggle").text('');
	$("#leixing").text('请选择');
	$("#jinyongbz").text('启用');
	$("#dikucyjkg").text('启用');
	$("#f-dcjl").text('单位').css('color','#777');
	$(".f-danwei").text('');
	$('#kucun').val(kucunsl);
	$('.check').removeClass("check2").addClass("check1");
	$('#checkHaocai').removeClass("check2").addClass("check1");
	$('.chazhc').css('display','none');
	$('#checkPingtk').removeClass("check1").addClass("check2");
	$('.modal-seh-laiyuan').css('display','none');
	$('.modal-seh-leixing').css('display','block');
	$(this).parent('ul').html('').css('display','none');
	$('#shangpinmc').val(mingcchen);
	$('#shengchancj').val('');
	$('#gongyings').val('');
	$("#shangpinjqcz").modal();
	$('#shangpinjqcz .modal-content').css({'top':'0px','left':'-55px'});
	showJingq();
});

$(document).ready(function () {
	//回车
	$("#mingcheng").focus();
	$("#cai-dialog").click(function () {	
	$("#dialog-chail").modal({backdrop:"static"});
	});
});

//取消按钮事件
$('.b-cancel').click(function () {
	$("#cedan").load(path+"yaopin.jsp");
});

var ptyaopinid="";
var ptmingcheng="";
var ptleixing="";
var ptbaozhuanggg="";
var ptchangjia="";
var ptpizhun="";
var pttiaoxingm="";
var jixing = '';
var ptbaozhuangdw = '';
$(".a-yaopin-add").focusout(function(){
	if($(".f-input-li li.xuanzeli").hasClass("hello")) {
		$(this).siblings(".f-input-li").css("display","block");
	}else{
		$(this).siblings(".f-input-li").css("display","none");
	}
});
$(document).on("click",".a-yaopinul-add li.xuanzeli",function(){
	var bValue = $(this).attr("index");
	var str = bValue.split(",");
	var pintaiypid = str[1];
	var uuid = str[2];
	fillluyaopin(pintaiypid,uuid);
	$(this).parent(".f-input-li").css("display","none");
}); 

function fillluyaopin(pintaiypid,uuid){
	//先通过平台药品id查询诊所id，如果查询到了，不允许重复添加
	$.ajax({
		url:'./zsyaopin/getZsYaopinByPintaiypid',
		type:'post',
		data:{pintaiypid:pintaiypid},
		success:function(data) {
			//if(data=='' && str[2] != '') {//查询不到，允许添加
				$.ajax({
		    		url:'./zsyaopin/getPtyapinByUUId',
		    		type:'post',
		    		data:{uuid:uuid},
		    		async:false,
		    		success:function(data) {
		    			if(data!=null) {
		    				jixing =data.jixing;
		    				if(data.baozhuangdw != null) {
		    					$('#baozhuangdw').val(data.baozhuangdw);
		    					$('.f-mrkydanwei').text(data.baozhuangdw);
		    					$('.f-mrkydanwei').css("color","#333");
		    					$('.f-danwei').text(data.baozhuangdw);
		    				}
		    				var leixing;
		    				if(data.leixing==0 ){
		                  		leixing="";
		                    }else if(data.leixing==1) {
		                    	leixing="饮片";
		                    	jixing = leixing;
	                    		$('#baozhuangdw').parent().find(".dropdown-toggle").css("color","#333");
		                    }else if(data.leixing==2) {
		                    	leixing="中成药";
		                    }else if(data.leixing==3) {
		                    	leixing="化学制药";
		                    }else if(data.leixing==4) {
		                    	leixing="生物制药";
		                    }else if(data.leixing==5) {
		                    	leixing="其他";
		                    }
		    				ptmingcheng=data.mingcheng;
		    				ptleixing=data.leixing;
		    				ptbaozhuanggg=data.baozhuanggg;
		    				ptbaozhuangdw = data.baozhuangdw;
		    				ptchangjia=data.shengchancj;
		    				ptpizhun=data.pizhunwh;
		    				pttiaoxingm=data.tiaoxingma;
		    				$('#mingcheng').val(data.mingcheng);
		    				if(leixing == '饮片'){
		    					$('#leixing').text('饮片');
		    				}else{
		    					$('#leixing').text(leixing);
		    				}
		    				$('#shangpmc').val(data.shangpinming || '');
		    				$('#hileixing').val(data.leixing)
		    				$('#leixing').css('color','#333');
		    				$('#baozhuanggg').val(data.baozhuanggg);
		    				$('#yp-shengchancj').val(data.shengchancj);
		    				$('#pizhunwh').val(data.pizhunwh);
		    				$('#tiaoxingma').val(data.tiaoxingma);
		    				if(data.chailingbz == 1) {
		    					$('#linshou1').prop('checked', true);
		    	    			$('#lbshi').attr('class', 'f-bz on');
		    				}else{
		    					$('#linshou2').prop('checked', true);
		    	    			$('#lbfou').attr('class', 'f-bz on');
		    				}
		    				$('#chailingsl').val(data.chailingsl);
		    				if(data.chailingdw!=null) {
		    					$('#chailingdw').text(data.chailingdw);
		    					$('#hichailingdw').val(data.chailingdw);
		    				}
		    				if($("#chailingdw").text() != "单位"){
		    					$("#chailingdw").css("color","#333");
		    				}
		    				$("#gongyingsypxj").val(data.gongyingshang)
		    				$('#yongfa').val(data.yongfa);
		    				$('#dancijl').val(data.dancijl);
		    				$('#dancijl').val(data.dancijl);
		    				$('#jixing').val(jixing);
		    				if(data.jiliangdw!=null) {
		    					$('#f-dcjl').text(data.jiliangdw);
		    					$('#f-dcjl').val(data.jiliangdw);
		    				}
		    				if($("#f-dcjl").text() != "单位"){
		    					$("#f-dcjl").css("color","#333");
		    				}
		    				$('#yongyaopl').val(data.yongyaopl);
		    				$('#f-mrkydanwei').val(data.morenkyl);
		    				if(data.morenkyl != '' && data.morenkyl != null){
		    					$("#morenkydw").css("color","#333");
		    				}
		    				$('#hipingtaiypid').val(data.id);
		    				$('#yizhu').val(data.yizhu);
		    			}
		    		}
		    	});
		}
	});
}
$(document).on('click','.yaopinlx li',function(){
	if($(this).text() == '饮片'){
		$('#jixing').val('');
		$('#jixing').val('饮片');
	}else{
		$('#jixing').val('');
	}
})
	    
$(document).on("click","#yongyaoplul li",function(){
	var bText = $(this).attr('index');
	$('#yongyaopl').val(bText);
	$(".f-input-li").css("display","none");
});

$(document).on("click","#yizhuul li",function(){
	var bText = $(this).text();
	var yizhu = $('#yizhu').val();
	$('#yizhu').val(yizhu + ',' + bText);
	$(".f-input-li").css("display","none");
	$('#yizhuul').html("");
	return false;
}); 

$(".f-adotc").on("click",function(){
	var radioId= $(this).attr("name");
	$(this).addClass("on").siblings().removeClass("on");
	if($(this).hasClass('on')){
		$("input.f-OTC").prop("checked",false); 
		$("#" + radioId).prop("checked",true);
	}
});
//btn模拟select模拟
$(document).on("click",".f-bt-li li",function(){
	var bText = $(this).text();
	var bValue = $(this).val();
	$(this).parent().parent().find(".dropdown-toggle").css("color","#333");
	$(this).parent().parent().find(".dropdown-toggle").text(bText);
	$(this).parent().parent().find(".dropdown-toggle").val(bValue);
	$(this).parent().parent().find(".dropdown-toggle").removeClass("n-invalid");
	$(this).parent().css("display","none");
});

//药品类型点击选择时
$(document).on("click", ".yaopinlx li", function () {
	var bText = $(this).text();
    var bValue = $(this).val();
    $(this).parent().parent().find(".dropdown-toggle").css("color","#333");
    $(this).parent().parent().find(".dropdown-toggle").text(bText);
    $("#hileixing").val(bValue);
    $(this).parent().parent().find(".dropdown-toggle").removeClass("n-invalid");
    $(this).parent().css("display","none");
	if($(this).text() == '饮片') {
	    jixing = '饮片';
    	$('#baozhuangdw').val('克');
	    // 不选择拆零
	    if($('[name	="linshou2"]').hasClass('on')) {
	    	$('.f-danwei2').text('克');
			$("#morenkydw").text('克');
			$("#morenkydw").css("color","#333");
	    } else {// 拆零
	    	$('.f-danwei').text('克');
	    }
		$('#baozhuangdw').parent().find(".dropdown-toggle").css("color","#333");
	}else{
		jixing = '';
		 $('#baozhuangdw').val('');
		 $('#chailingbzdw').text('');
	}
});

/*药品次剂量为适量时，数量不可编辑*/
$(document).on("click",".dropdown-menu li",function() { 
	var _text = $("#f-dcjl").text();
	if(_text == "适量"){
		$("#dancijl").attr('disabled',true).val('');
	}else{
		$("#dancijl").attr('disabled',false);
	}
	$(this).parent().css("display","none");
});
//input模拟select模拟
$(".dropdown-toggle").focusin(function(){
   $(this).siblings(".f-input-li").css("display","block");
});

$(document).on("mouseover",".f-input-li li",function(){
	$(this).addClass("hello");
});
$(document).on("mouseout",".f-input-li li",function(){
	$(this).removeClass("hello");
});

$(document).on("click","#yongfaul li",function (){
	var bText = $(this).text();
	$(this).parent().siblings(".dropdown-toggle").val(bText);
	$(this).parent(".dropdown-menu").css("display","none");
});

$(document).on("click","#yongyaoplul li",function (){
	var bText = $(this).text();
	$(this).parent().siblings(".dropdown-toggle").val(bText);
	$(this).parent(".dropdown-menu").css("display","none");
});
$(document).on("click","#danci-jldw li",function (){
	$("#f-dcjl").css("border","solid 1px #ccc");
});
  //支持零售关闭 TODO
$("label[name='linshou2']").click(function(){
	$("label[name='linshou1']").removeClass("on");
	$("label[name='linshou2']").addClass("on");
	$(".f-cailinhs").val("");
 	$(".f-cailindw").val("");
 	$(".f-cailindw").text("单位");
 	$(".f-danwei2").addClass("f-danwei");
 	if($(".f-baozhuangdw").val() !="" ||$(".f-baozhuangdw").val() !=null){
 		var bText = $(".f-baozhuangdw").val();
 	 	$(".f-danwei").text(bText);
 	 	$(".f-mrkydanwei").text(bText);
 	}
 	$("#mrky1_Li2").remove();
	$("#show-hidden").css("display","none");
	$(".small-zhezhao").css("display","none");
	$(".chailingbz").prop("checked",false);
	$("#linshou2").prop("checked",true);
	$('#chailingsl').val('');
	resetKucunsl();
});
//支持零售开启
$("#dialog-chail .queding").click(function(){
	$("label[name='linshou2']").removeClass("on");
	$("label[name='linshou1']").addClass("on");
	$("#dialog-chail").modal("hide") ;
	$(".small-zhezhao").css("display","block");
	$("#cailjgf").css("display","block");
	$(".f-danwei2").removeClass("f-danwei");
	$("#show-hidden").css("display","block");
	if($(".f-cailindw").text() !="单位"){
		var bText = $(".f-cailindw").text();
		$(".f-danwei2").text(bText);
		$("#morenkydw").text(bText);
		$("#morenkydw").css("color","#333");
	}
	$("#mrky1_Li1").remove();
	var baozhuangdw = $('#baozhuangdw').val();
	var chailingdw = $('#chailingdw').text();
	if(chailingdw !='单位'&&chailingdw !=''){
		var mrky_Content =	'<li id="mrky1_Li1">'+baozhuangdw+'</li>'+
							'<li id="mrky1_Li1">'+chailingdw+'</li>';
	}else {
		var mrky_Content =	'<li id="mrky1_Li1">'+baozhuangdw+'</li>';
	}
	$("#morengkaiyao").html(mrky_Content);
	$(".chailingbz").prop("checked",false);
	$("#linshou1").prop("checked",true);
});


 //点击拆零单位时库存数量发生变化
$(document).on("click","#cailindw li",function(){
	if(yaopinxjkcsl == '' || yaopinxjkcsl == null){return;}
	 var huansuanbi = $('#chailingsl').val();
	 if(huansuanbi!='' && !isNaN(huansuanbi)) {
		 $('#kucun').val(parseFloat(huansuanbi) * parseFloat(yaopinxjkcsl));
	 }
	 $(this).parent().css("display","none");
});
// 拆零数量变化库存数量
$('#chailingsl').keyup(function(){
	if(yaopinxjkcsl == '' || yaopinxjkcsl == null){return;}
	var huansuanbi = $(this).val();
	if(huansuanbi!=''&&!isNaN(huansuanbi)) {
		$('#kucun').val(parseFloat(huansuanbi) * parseFloat(yaopinxjkcsl));
	}
});

var yaopinxjkcsl; // 药品新建库存数量
$('#kucun').blur(function(){
	yaopinxjkcsl = $('#kucun').val();	
});

// 拆零取消回复库存数量
function resetKucunsl() {
	$('#kucun').val(yaopinxjkcsl);
}

// 包装单位可输入
$("#baozhuangdw").blur(function() {
	var baozhuangdw = $("#baozhuangdw").val();
	if(getByteLen(baozhuangdw) > 4) {
		notifyWarning('包装规格请输入1-2个字符');
		this.focus();
		$("#baozhuangdw").addClass("n-invalid");
		return false;
	}else{
		$("#baozhuangdw").removeClass("n-invalid");
	}
});

$("#dialog-chail .cancel").click(function(){	
	$("#dialog-chail").modal("hide"); 
	$("label[name='linshou1']").removeClass("on");
	$("label[name='linshou2']").addClass("on");
	$("#show-hidden").css("display","none");
	$(".small-zhezhao").css("display","none");
	$(".chailingbz").prop("checked",false);
	$("#linshou2").prop("checked",true);
	resetKucunsl();
});

//库存下限事件
$(".f-kucunxiaxian").focusout(function(){
	if($(this).val() != ""){
		$(".f-yujing").val("1");
		$(".f-yujing").text("开启");
		$("#open-close").css("display","block");
	}else{
		$("#open-close").css("display","none");
		$(".f-yujing").val("");
		$(".f-yujing").text("请选择");
	}
});
// 包装单位ULLi点击
$("#baozhuangdwul li").click(function () {
	$("#mrky1_Li1").remove();
	var bText = $(this).text();
	$(this).parent().siblings("#baozhuangdw").val(bText);
	var chailingdw = $('#chailingdw').text();
	if (chailingdw != '单位' && chailingdw != '') {
		var mrky_Content =	'<li id="mrky1_Li1">' + bText + '</li>'+
							'<li id="mrky1_Li1">' + chailingdw + '</li>';
		$(".f-mrkydanwei").text(chailingdw);
    	$(".f-danwei").text(bText);
	} else {
		var mrky_Content =	'<li id="mrky1_Li1">' + bText + '</li>';
		$('#chailingdw').css("color","#777");
		$(".f-danwei").text(bText);
		$(".f-danwei2").text(bText);
		$(".f-mrkydanwei").text(bText).css("color","#333");
	}
    $("#morengkaiyao").html(mrky_Content);
	if ($('[name="linshou2"]').hasClass('on')) {
    	$("#morenkydw").css("color","#333");
    	$(".f-mrkydanwei").text(bText);
    	$(".f-danwei").text(bText);
    	$("#baozhuangdw").removeClass('n-invalid');
    	$(".f-input-li").css("display", "none");
    	$(".label-dis").css("display", "block");
	} else {
    	$("#baozhuangdw").removeClass('n-invalid');
    	$(".f-input-li").css("display", "none");
    	$(".label-dis").css("display", "block");
	}
});
// 剂型输入事件
$(document).on("input", "#jixing", function () {
	getJixingByDmmc($(this));
});
$(document).on("focusin", "#jixing", function () {
	getJixingByDmmc($(this));
});
$(document).on("click", "#jixingul li", function () {
	$(this).parent().parent().find('#jixing').val($(this).text());
});

// 包装单位INPUT事件
$(document).on("input", "#baozhuangdw", function () {
	$("#mrky1_Li1").remove();
	var bValue = $(this).val();
	if (bValue != '' && bValue != null){
		var chailingdw = $('#chailingdw').text();
	    if (chailingdw != '单位' && chailingdw != '') {
			var mrky_Content =	'<li id="mrky1_Li1">' + bValue + '</li>' +
								'<li id="mrky1_Li1">' + chailingdw + '</li>';
			$("#morenkydw").css("color","#333");
	    	$(".f-mrkydanwei").text(chailingdw);
	    	$(".f-danwei2").text(chailingdw);
	    	$(".f-danwei").text(bValue);
		} else {
		    var mrky_Content = '<li id="mrky1_Li1">'+ bValue + '</li>';
		    $(".f-mrkydanwei").text(bValue);
		    $("#morenkydw").css("color","#333");
    		$(".f-danwei").text(bValue);
    		$(".f-danwei2").text(bValue);
	    }
		$("#morengkaiyao").html(mrky_Content);
 	} else {
		$("#morenkydw").css("color","#777");
		$("#morenkydw").text('单位');
	}
});
// 拆零单位Li事件
$("#cailindw li").click(function () {
	$("#mrky1_Li2").remove();
	var bText = $(this).text();
	var baozhuangdw = $('#baozhuangdw').val();
	if (baozhuangdw !='' || baozhuangdw != null) {
		var mrky_Content = '<li id="mrky1_Li2">' + bText + '</li>' +
							'<li id="mrky1_Li2">' + baozhuangdw + '</li>';
	} else {
		var mrky_Content =	'<li id="mrky1_Li2">' + bText + '</li>';
	}
	$("#morengkaiyao").html(mrky_Content);
	$("#morenkydw").css("color","#333");
	$(".f-mrkydanwei").text(bText);
	$(".f-danwei2").text(bText);
});

$("#bieming").blur(function () {
	var biemingval = $("#bieming").val();
	var reg = /[a-zA-Z1-9]/;
	if(reg.test(biemingval)&&biemingval.length==1) {
		notifyWarning('别名太短，请重新输入');
		$(this).focus();
		$("#bieming").addClass("n-invalid");
		return false;
	}else{
		$("#bieming").removeClass("n-invalid");
	}
});

$("#mingcheng").blur(function () {
	var biemingval = $("#mingcheng").val();
	var reg = /[a-zA-Z1-9]/;
	var yanzhengtongguo = false;
	if (reg.test(biemingval)&&biemingval.length==1) {
		if ($(this).parent().find('.dropdown-menu li').hasClass('hello')) {
			$("#mingcheng").removeClass("n-invalid");
		} else {
			$(this).focus();
			notifyWarning('药品名称太短，请重新输入');
			$("#mingcheng").addClass("n-invalid");
			return false;
		}
	} else {
		$("#mingcheng").removeClass("n-invalid");
	}
});

$("#chailingsl").blur(function () {
	var clslval = $(this).val();
	var thisPlay = $("#show-hidden").css("display");
	if(clslval<1&&thisPlay=="block"){
		notifyWarning('拆零数量不能小于1');
		$(this).addClass("n-invalid");
	}else{
		$(this).removeClass("n-invalid");
	}
});

$("#jixing").blur(function(){
	var ischufa = $(this).parent().find('#jixingul li').hasClass("hello");
	var jixingval = $(this).val();
	if(jixingval.length > 20){
		notifyWarning('可输入最大长度为20个字符');
		$(this).addClass("n-invalid");
	}else if(jixingval == ''&& !ischufa){
		notifyWarning('剂型内容不能为空');
		$(this).addClass("n-invalid");
	}else{
		$(this).removeClass("n-invalid");
	}
});

$(document).off('*','#formSave');
vilidateform();
function vilidateform() {
	$('#formSave').on('valid.form', function (e) {
	$('#hichailingdw').val($('#chailingdw').text());
	$('#hijiliangdw').val($('#f-dcjl').text());
	$('#himorenkydw').val($('#morenkydw').text());
	$('#hijinyongbz').val($('#jinyongbz').val());
	$('#hidikucyjkg').val($('#dikucyjkg').val());
	if($('#dancijl').val() != '') {
		if($('#f-dcjl').text()=='单位') {
			notifyWarning('请填写单次剂量单位');
			$("#f-dcjl").css("border","solid 1px #ff0000");
			return false;
		}
	}
	
	// 别名验证
	var biemingval = $("#bieming").val();
	var reg = /[a-zA-Z1-9]/;
	if(reg.test(biemingval)&&biemingval.length==1) {
		notifyWarning('别名太短，请重新输入');
		$("#bieming").addClass("n-invalid");
		return false;
	}
	var mingchengval = $("#mingcheng").val();
	var reg = /[a-zA-Z1-9]/;
	if(reg.test(mingchengval)&&mingchengval.length==1) {
		notifyWarning('药品名称太短，请重新输入');
		$("#mingcheng").addClass("n-invalid");
		return false;
	}
	if(ptbaozhuanggg != $('#baozhuanggg').val()) {
		$('#hipingtaiypid').val('');
	}
	if(ptbaozhuangdw != $('#baozhuangdw').val()) {
		$('#hipingtaiypid').val('');
	}
	
	if(ptpizhun==null){
		ptpizhun="";
	}
	if(ptchangjia==null){
		ptchangjia="";
	}
	if(ptleixing==$('#hileixing').val()&&ptmingcheng==$("#mingcheng").val()
		&& ptchangjia==$("#yp-shengchancj").val()){
	}else{
		$('#hipingtaiypid').val('');
	}

	var clslval = $("#chailingsl").val();
	var thisPlay = $("#show-hidden").css("display");
	var chailingdw =$("#chailingdw").text();
	if(clslval<1&&thisPlay=="block"){
		notifyWarning('拆零数量不能小于1');
		$("#chailingsl").focus();
		$("#chailingsl").addClass("n-invalid");
		return false;
	}else{
		$("#chailingsl").removeClass("n-invalid");
	}
 	// 包装单位
	var baozhuangdw = $("#baozhuangdw").val();
	if (getByteLen(baozhuangdw) > 4) {
		notifyWarning('包装规格请输入1-2个字符');
		$("#baozhuangdw").addClass("n-invalid");
		return false;
	} else {
		$("#baozhuangdw").removeClass("n-invalid");
	}
	    
	if (chailingdw == "单位"&&thisPlay=="block") {
		notifyWarning('拆零单位必填');
		$("#chailingdw").addClass("n-invalid");
		return false;
	} else {
		$("#chailingdw").removeClass("n-invalid");
	}
	
	var jixingval = $("#jixing").val();
	if(jixingval.length > 20){
		notifyWarning('可输入最大长度为20个字符');
		$("#jixing").addClass("n-invalid");
		return false;
	}else if(jixingval.trim() == ''){
		notifyWarning('剂型内容不能为空');
		$("#jixing").addClass("n-invalid");
		return false;
	}else{
		$(this).removeClass("n-invalid");
	};
		
	if ($('#baozhuangdw').val() == '' || $('#baozhuangdw').val() == null) {
		notifyWarning('包装规格单位必填');
		$("#baozhuangdw").addClass("n-invalid");
		$('#baozhuangdw').focus();
		return false;
	} else if($('#hileixing').val()=='') {
		notifyWarning('药品类型必填');
		$("#leixing").addClass("n-invalid");
		return false;
	}
	$("#baozhuangdw").removeClass("n-invalid");
	$('#tcmingchengqr').modal();
	});
}
// 名称弹窗确认按钮
$(document).off('click', '#btnYaoPinAdd');
$(document).on('click','#btnYaoPinAdd',function () {
	$('#btnYaoPinAdd').attr('disabled', true);
	$.ajax({
		url: path + '/zsyaopin/xinjianypkc',
		type: 'post',
		data: $('#formSave').serialize(),
		success: function(data) {
		//判断是否请求成功
		$('#tcmingchengqr').modal('hide');
		if (data == 'success') {
			var presuccmsg=encodeURI(encodeURI('药品保存成功'));
			$('#btnYaoPinAdd').attr('disabled',false);
			var sjc =new Date().getTime();
			$("#cedan").load(path + "/views/kucun/yaopin.jsp?msg=" + presuccmsg + "&sjc=" + sjc);
		} else if (data == 'fail') {
			notifyDanger(data);
		} else {
			$('#btnYaoPinAdd').removeAttr('disabled');
			notifyWarning("做梦我选白日梦");
		}
		}
	});
});
var jixing = '';
//用法点击聚焦事件
$(document).on('focusin', '[name="yongfa"]', function () {
	getYongfazd(this, jixing);
});
//整体去掉input的autocomplete
$("input:text").attr("autocomplete", "off");

//判断库存批次是否开启
var kucunpckg;
function getYaopintjcs(prekucunpckg){
	if(prekucunpckg == true){
		$("#kucun").attr("readOnly","readOnly");
		$("#kucun").attr("disabled",true).css("background-color","#eee");
		$("#kucun").val(0);
	}else{
		$("#kucun").removeAttr("readOnly");
		$("#kucun").val();
	}     
}